<script setup>
import { onMounted, ref } from 'vue';
import { getMessagePage } from '../../../apis/messageApi';

  const page = ref(1)
  // 每页包含数据条数
  const pageSize = ref(5)
  // 是否为空列表
  const isEmpty = ref(false)
  const isLoading = ref(false)
    // 任务列表数据
    const announceList = ref([])
    const getNotifyList = () => {
      isLoading.value = true
      getMessagePage(200,page.value,pageSize.value,res => {
        if(res.code === 200){
          for(let i=0;i < res.data.items.length;i++){
            announceList.value.push(res.data.items[i])
          }
          isEmpty.value = announceList.value.length === 0;
        }else{
          showFailToast('获取公告列表失败')
        }
        isLoading.value = false
      })
  }
  const goDetail = (item) => {
    // uni.navigateTo({
    //   url:'/subpkg_message/content/index?id=' + item.id
    // })
  }
  onMounted(() => {
    getNotifyList()
  })
</script>
<template>
   <scroll-view class="scroll-view" refresher-enabled scroll-y>
      <view class="scroll-view-wrapper">
        <view class="message-action">
          <text class="iconfont icon-clear"></text>

          全部已读
        </view>

        <uni-list :border="false">
          <uni-list-item
            @click="goDetail(announce)"
            v-for="announce in announceList"
            :key="announce.id"
            :to="`/subpkg_message/content/index?id=${announce.id}`"
            ellipsis="1"
            :title="announce.title"
            :right-text="announce.created"
          >
            <template v-slot:header>
              <text v-if="!announce.isRead" class="dot"></text>

            </template>

          </uni-list-item>

        </uni-list>

        <view v-if="isEmpty" class="message-blank">暂无消息</view>

      </view>

    </scroll-view>
</template>

<style lang="scss" scoped>
  @import './styles.scss';
</style>
